package com.example.myblog.utils;

import com.example.myblog.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author yx
 */
@Component
public class RabbitMQUtil {
    RabbitTemplate rabbitTemplate;
    @Autowired
    public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public void saveBlog(String blogId) {
        rabbitTemplate.convertAndSend(RabbitMQConfig.BLOG_EXCHANGE,RabbitMQConfig.KEY_BLOG_SAVE,blogId);
    }

    public void removeBlog(String blogId) {
        rabbitTemplate.convertAndSend(RabbitMQConfig.BLOG_EXCHANGE,RabbitMQConfig.KEY_BLOG_REMOVE,blogId);
    }
}
